package com.chinanet.netelementmodel;

import com.chinanet.entry.netelement.Attr;
import com.chinanet.entry.netelement.AttrType;
import com.chinanet.entry.netelement.WorkInterFace;

import java.util.HashMap;
import java.util.Map;


public class Networkmanagement_choice implements WorkInterFace {

	@Override
	public String getName() {
		return "网管判断";
	}

	@Override
	public String getDesciption() {
		return "";
	}

	@Override
	public int getVersion() {
		return 0;
	}

	@Override
	public Attr[] getInAttrs() {
		Attr[] in=new Attr[1];
		in[0]=new Attr("InString","包含有网管名称信息的字符串", AttrType.TYPE_String,true);
		return in;
	}

	@Override
	public Attr[] getOutAttrs() {
		Attr[] out=new Attr[2];
		out[0]=new Attr("outType","0：未知；1：华为；2：中兴；3：烽火",AttrType.TYPE_Int,true);
		out[1] = new Attr("log", "日志输出", AttrType.TYPE_String, true);
		return out;
	}

	@Override
	public Map<String, Object> init(Map<String, Object> data) {
		Map<String,Object> map=new HashMap<String, Object>();
		String inString=String.valueOf(data.get("InString"));
		System.out.println(inString);
		int outType=0;
		if(inString.indexOf("华为")!=-1||inString.indexOf("HW")!=-1){
			outType=1;
		}else if(inString.indexOf("中兴")!=-1){
			outType=2;
		}else if(inString.indexOf("FH")!=-1){
			outType=3;
		}
		map.put("outType", outType);
		map.put("log","判断出网管为："+outType);
		return map;
	}

}
